from fastapi import Depends, FastAPI
from .config import settings
# from .dependencies import get_query_token, get_token_header
from .database import get_session ,create_db_and_tables
from .routers import wikipedia, wikidata

from .services import initialize_service, shutdown_service


SessionDep = Depends(get_session)

app = FastAPI(dependencies=[Depends(get_session)])

@app.on_event("startup")
async def startup_event():
    await initialize_service()
    
    create_db_and_tables()

@app.on_event("shutdown")
async def shutdown_event():
    await shutdown_service()


@app.get("/info")
async def info():
    return {
        "app_name": settings.app_name,
        "admin_email": settings.admin_email,
        "items_per_user": settings.items_per_user,
    }

app.include_router(
    wikipedia.router,
    prefix="/wikipedia",
    tags=["wikipedia"],
    # dependencies=[Depends(get_token_header)],
    responses={418: {"description": "I'm a teapot"}},
)

app.include_router(
    wikidata.router,
    prefix="/wikidata",
    tags=["wikidata"],
    # dependencies=[Depends(get_token_header)],
    responses={418: {"description": "I'm a teapot"}},
)

@app.get("/")
async def root():
    return {"message": "Hello Bigger Applications!"}